ASCII 是美國信息交換標準代碼的縮寫。它是一種字符編碼標準。例如英文字母 A 的 ASCII 值是 65。Python 提供了這個函數來獲取對象的可打印表示。它接受一個參數,它是一個對象,可以是列表、字符串、元組等。函數的輸出是十六進製表示。非 ascii 字符可以使用 \x、\u 或 \U 轉義符進行轉義。
用法
語法是 -
Syntax:
ascii(object)
示例
打印具有單個字符和多個字符的字符串。
# Individual Characters
print(ascii("Ω"))
print(ascii("θ"))
# A string int multiple characters
print(ascii("TΨtΦrial"))
輸出
運行上麵的代碼給我們以下結果 -
'\u03a9' '\u03b8' 'T\u03a8t\u03a6rial'
相關用法
- Python Tweepy API.mentions_timeline()用法及代碼示例
- Python Tweepy API.get_user()用法及代碼示例
- Python Tweepy API.list_timeline()用法及代碼示例
- Python Tweepy API.add_list_members()用法及代碼示例
- Python Tweepy API.create_block()用法及代碼示例
- Python Tweepy API.trends_closest()用法及代碼示例
- Python Tweepy API.send_direct_message()用法及代碼示例
- Python Tweepy API.destroy_status()用法及代碼示例
- Python Tweepy API.destroy_saved_search()用法及代碼示例
- Python Tweepy API.get_list()用法及代碼示例
- Python Tweepy API.favorites()用法及代碼示例
- Python Tweepy API.blocks_ids()用法及代碼示例
- Python Tweepy API.configuration()用法及代碼示例
- Python Tweepy API.home_timeline()用法及代碼示例
- Python Tweepy API.unretweet()用法及代碼示例
- Python Tweepy API.create_mute()用法及代碼示例
- Python Tweepy API.search_users()用法及代碼示例
- Python Tweepy API.show_list_member()用法及代碼示例
- Python Tweepy API.create_list()用法及代碼示例
- Python Tweepy API.list_members()用法及代碼示例
注:本文由純淨天空篩選整理自Pradeep Elance大神的英文原創作品 Ascii() in python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。