網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
打印類的所有屬性和方法
利用dir(obj)方法獲得obj對(duì)象的所有屬性和方法名,返回一個(gè)list。
for item in dir(top_k_metergroup): ?#top_k_metergroup是某類的一個(gè)實(shí)例化對(duì)象
? ? print(item)
__class__
__delattr__
__dict__
__dir__
__doc__
__eq__
__format__
__ge__
__getattribute__
__getitem__
__gt__
__hash__
__init__
__init_subclass__
__le__
__lt__
__module__
__ne__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__sizeof__
__str__
__subclasshook__
__weakref__
_aggregate_metadata_attribute
_check_kwargs_for_full_results_and_sections
_collect_stats_on_all_meters
_convert_physical_quantity_and_ac_type_to_cols
_energy_per_meter_with_remainder
_meter_generators
_plot_area
_plot_energy_bar
_plot_sankey
_plot_separate_lines
_prep_kwargs_for_sample_period_and_resample
_replace_none_with_meter_timeframe
_set_sample_period
activation_series
activity_histogram
all_meters
appliances
available_ac_types
available_physical_quantities
available_power_ac_types
average_energy_per_period
building
call_method_on_all_meters
clear_cache
contains_meters_from_multiple_buildings
correlation
correlation_of_sum_of_submeters_with_mains
dataframe_of_meters
dataset
describe
disabled_meters
dominant_appliance
dominant_appliances
draw_wiring_graph
dropout_rate
energy_per_meter
entropy
entropy_per_meter
fraction_per_meter
from_list
from_other_metergroup
get_activations
get_labels
get_timeframe
good_sections
groupby
identifier
import_metadata
instance
is_site_meter
label
load
load_series
mains
matches
matches_appliances
meters
meters_directly_downstream_of_mains
min_off_duration
min_on_duration
mutual_information
name
nested_metergroups
on_power_threshold
pairwise
pairwise_correlation
pairwise_mutual_information
plot
plot_activity_histogram
plot_autocorrelation
plot_good_sections
plot_lag
plot_multiple
plot_power_histogram
plot_spectrum
plot_when_on
power_series
power_series_all_data
proportion_of_energy
proportion_of_energy_submetered
proportion_of_upstream
proportion_of_upstream_total_per_meter
sample_period
select
select_top_k
select_using_appliances
simultaneous_switches
sort_meters
submeters
switch_times
total_energy
train_test_split
union
upstream_meter
uptime
use_alternative_mains
values_for_appliance_metadata_key
vampire_power
when_on
wiring_graph
python中更多種類的打印
1.print("." * 10) 是輸出10個(gè) "."?
把每個(gè)字母相加輸出就可以得到相應(yīng)的字符串。
print("Mary had a little lamb.")
print("Its fleece was white as {}." .format('snow')) #將snow放入字符串的相應(yīng)位置
print("And everywhere that Mary went.")
print("." * 10) # what'd that do?
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
# watch that comma at the end. try removing it to see what happens
print(end1 + end2 + end3 + end4 + end5 + end6, end = ' ' ) # end = ' ' 為連接前后的成分,使其不換行
print(end7 + end8 + end9 + end10 + end11 + end12)
運(yùn)行結(jié)果:
2.用了一個(gè)自定義的函數(shù) formatter
其作用是:
<1>.取第1行定義的 formatter 字符串。
<2>.調(diào)用它的 format 函數(shù),這相當(dāng)于告訴它執(zhí)行一個(gè)叫 format 的命令行命令。
<3>.給 format 傳遞4個(gè)參數(shù),這些參數(shù)和 formatter 變量中的{}匹配,相當(dāng)于將參數(shù)傳遞給了 format 這個(gè)命令。
<4>.在 formatter 上調(diào)用 format的結(jié)果是一個(gè)新字符串,其中的{}被4個(gè)變量替換掉了,這就是 print 現(xiàn)在打印出的結(jié)果。
formatter="{} {} {} {}"
print(formatter.format(1,2,3,4))
print(formatter.format("one","two","three","four"))
print(formatter.format(True,False,False,True))
print(formatter.format(formatter,formatter,formatter,formatter))
print(formatter.format(
"Try your",
"Own text here",
"Maybe a poem",
"or a song about fear"
))
運(yùn)行結(jié)果:
3.這個(gè)主要是講定義的字符串可以直接打印出來(lái)
“\n” 是換行符。
# Here's some new strange stuff, remember type it exactlyself.
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
print("Here are the days: ", days)
print("here are the months: ", months)
print("""
There's something going on here.
With the three double-quotes.
we'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
""")
運(yùn)行結(jié)果:
原文鏈接:https://blog.csdn.net/sunmingyang1987/article/details/116228492
相關(guān)推薦
- 2022-11-08 詳解Python中數(shù)據(jù)處理的方法總結(jié)及實(shí)現(xiàn)_python
- 2022-07-15 ASP.NET?Core獲取正確查詢字符串參數(shù)示例_實(shí)用技巧
- 2021-12-08 C++數(shù)組的定義詳情_(kāi)C 語(yǔ)言
- 2022-10-25 記一次生產(chǎn)環(huán)境死鎖問(wèn)題分析
- 2022-09-16 nginx緩存以及清除緩存的使用_nginx
- 2022-03-04 運(yùn)行 npm 會(huì)彈出詢問(wèn) “你要如何打開(kāi)這個(gè)文件?“
- 2022-09-17 Python利用AutoGrad實(shí)現(xiàn)自動(dòng)計(jì)算函數(shù)斜率和梯度_python
- 2022-10-01 Go語(yǔ)言異步API設(shè)計(jì)的扇入扇出模式詳解_Golang
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支