最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python實現(xiàn)打印類的所有屬性和方法

 更新時間:2022年05月19日 10:01:19   作者:ACE-Mayer  
這篇文章主要介紹了python實現(xiàn)打印類的所有屬性和方法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

打印類的所有屬性和方法

利用dir(obj)方法獲得obj對象的所有屬性和方法名,返回一個list。

for item in dir(top_k_metergroup): ?#top_k_metergroup是某類的一個實例化對象
? ? 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個 "." 

把每個字母相加輸出就可以得到相應的字符串。

print("Mary had a little lamb.")
print("Its fleece was white as {}." .format('snow'))   #將snow放入字符串的相應位置
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)

運行結(jié)果:

2.用了一個自定義的函數(shù) formatter

其作用是:

<1>.取第1行定義的 formatter 字符串。

<2>.調(diào)用它的 format 函數(shù),這相當于告訴它執(zhí)行一個叫 format 的命令行命令。

<3>.給 format 傳遞4個參數(shù),這些參數(shù)和 formatter 變量中的{}匹配,相當于將參數(shù)傳遞給了 format 這個命令。

<4>.在 formatter 上調(diào)用 format的結(jié)果是一個新字符串,其中的{}被4個變量替換掉了,這就是 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"       
))

運行結(jié)果:

3.這個主要是講定義的字符串可以直接打印出來

“\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.
   """)

運行結(jié)果:

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python+Pygame實戰(zhàn)之俄羅斯方塊游戲的實現(xiàn)

    Python+Pygame實戰(zhàn)之俄羅斯方塊游戲的實現(xiàn)

    俄羅斯方塊,作為是一款家喻戶曉的游戲,陪伴70、80甚至90后,度過無憂的兒時歲月,它上手簡單能自由組合、拼接技巧也很多。本文就來用Python中的Pygame模塊實現(xiàn)這一經(jīng)典游戲,需要的可以參考一下
    2022-12-12
  • Python使用requirements.txt和pip打包批量安裝的實現(xiàn)

    Python使用requirements.txt和pip打包批量安裝的實現(xiàn)

    本文主要介紹了Python使用requirements.txt和pip打包批量安裝的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-02-02
  • 對Pyhon實現(xiàn)靜態(tài)變量全局變量的方法詳解

    對Pyhon實現(xiàn)靜態(tài)變量全局變量的方法詳解

    今天小編就為大家分享一篇對Pyhon實現(xiàn)靜態(tài)變量全局變量的方法詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-01-01
  • Python自動化實戰(zhàn)之接口請求的實現(xiàn)

    Python自動化實戰(zhàn)之接口請求的實現(xiàn)

    本文為大家重點介紹如何通過 python 編碼來實現(xiàn)我們的接口測試以及通過Pycharm的實際應用編寫一個簡單接口測試,感興趣的可以了解一下
    2022-05-05
  • Python實現(xiàn)雙進程防止單點故障實例深度探究

    Python實現(xiàn)雙進程防止單點故障實例深度探究

    在分布式系統(tǒng)中,確保系統(tǒng)的高可用性是至關(guān)重要的,本文將深入探討如何使用Python實現(xiàn)雙進程自我保護機制,以應對單點故障,確保系統(tǒng)穩(wěn)定運行,將通過詳實的示例代碼,介紹雙進程自我保護的原理、實現(xiàn)步驟以及可能遇到的挑戰(zhàn)
    2024-01-01
  • 使用BeautifulSoup4解析XML的方法小結(jié)

    使用BeautifulSoup4解析XML的方法小結(jié)

    這篇文章主要介紹了使用BeautifulSoup4解析XML的方法小結(jié),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-12-12
  • Python3實現(xiàn)英文字母轉(zhuǎn)換哥特式字體實例代碼

    Python3實現(xiàn)英文字母轉(zhuǎn)換哥特式字體實例代碼

    這篇文章主要給大家介紹了關(guān)于Python3實現(xiàn)英文字母轉(zhuǎn)換哥特式字體的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-09-09
  • 關(guān)于numpy數(shù)組軸的使用詳解

    關(guān)于numpy數(shù)組軸的使用詳解

    今天小編就為大家分享一篇關(guān)于numpy數(shù)組軸的使用詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • 如何從Python的cmd中獲得.py文件參數(shù)

    如何從Python的cmd中獲得.py文件參數(shù)

    這篇文章主要介紹了如何從Python的cmd中獲得.py文件參數(shù)操作,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-05-05
  • opencv與numpy的圖像基本操作

    opencv與numpy的圖像基本操作

    這篇文章主要介紹了opencv與numpy的圖像基本操作,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-03-03

最新評論

湘潭县| 航空| 吉水县| 休宁县| 嘉善县| 克什克腾旗| 昌黎县| 甘谷县| 保靖县| 定远县| 涿鹿县| 波密县| 富宁县| 瑞昌市| 邯郸市| 古田县| 民丰县| 博爱县| 武定县| 锦州市| 永修县| 泌阳县| 冕宁县| 汾阳市| 武义县| 南郑县| 襄垣县| 鹤岗市| 开化县| 建德市| 富裕县| 稷山县| 伊金霍洛旗| 吴川市| 云梦县| 武平县| 呼玛县| 徐州市| 神池县| 华坪县| 海南省|