我想從原始文件中讀取數據並替換文本中的格式。 比如...在一個原始文件是這樣的: hello {0}, my name id {1}, my age is {2}....
當我使用的String.format,如下圖所示,文字失去了它的縮進。 String data = readTextFile(this, R.raw.input);
data = String.format(data, "
我的代碼: new_account = sys.argv[1]
confirm_new = input("Would you like to add {} to the dictionary?" +
"\ny or n\n".format(new_account))
這不格式化字符串放置變量替代{}。這是怎麼回事?
現在已經到了將所有打印轉換爲我所維護的庫中的日誌記錄調用的時候了。一些打印話費使用str.format,像這樣(簡化): >>> n = 4000000
>>> print(f"this bird wouldn't voom if you put {n:,} volts through it!")
this bird wouldn't voom if you put 4,000,000 vol