create account

MiniBitePython - #2 Output result to .txt file with cmd | 使用cmd將結果輸出到.txt文件 by nuagnorab

View this thread on: hive.blogpeakd.comecency.com
· @nuagnorab ·
$9.86
MiniBitePython - #2 Output result to .txt file with cmd | 使用cmd將結果輸出到.txt文件
>疫情反覆,當大家安在家中,有沒有想學點什麼?
我在工作時有同事問起有關初學 Python 時的問題,希望可以有一些實用點的方式來學習,可惜網上缺少這種資訊。(說穿了是不太會使用Google)。所以我想創一個 Series,搞點簡單的 use case 來讓他學習。以下是系列記錄。

>以下合適知曉如何使用Terminal的朋友。

---

Previously on miniBitePython, 
>前期提要,
[MiniBitePython - #1 Create python .py script | 創建Python腳本](https://peakd.com/hive-105017/@nuagnorab/minibitepython-1-create-python-py-script-or-python)。

### 3. Output result to .txt file

1. After we confirmed that our script calculates correctly. We want to output the result ```4950``` to a separate ```.txt``` since the python script will not store my result.

2. Go to terminal and type in ```python sum_num.py > result.txt```.
This command will run the ```sum_num.py``` and then save the result (4950) to the ```result.txt```. And if the .txt does not exist in the current directory, this command will help create one.


![image.png](https://cdn.steemitimages.com/DQmPM5Fg26qA9SbayuacscZANCeCwyrUHdiUpvcKxNAgvsv/image.png)

>1.確認腳本正確計算後。 我們想要將結果```4950```輸出到獨立的“```.txt```中,因為python腳本不會存儲結果。

>2.轉到終端並輸入```python sum_num.py> result.txt```。
該命令將運行```sum_num.py```,然後將結果(4950)保存到```result.txt```。 如果當前目錄中不存在該命名的```result.txt```,則此命令將幫助創建一個。

Summary:

We learned to output a python script result in a ```.txt``` file with a terminal command.

>摘要:
我們學會了使用終端命令將python腳本結果輸出到`.txt`文件中。
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 231 others
👎  
properties (23)
authornuagnorab
permlinkminibitepython-2-output-result-to-txt-file-with-cmd-or-cmd-txt
categoryhive-105017
json_metadata{"app":"peakd/2020.07.1","format":"markdown","tags":["cn","cn-reader","cn-curation","palnet","neoxian","minibitepython","cn-programming","build-it","technology"],"users":["nuagnorab"],"links":["/hive-105017/@nuagnorab/minibitepython-1-create-python-py-script-or-python"],"image":["https://cdn.steemitimages.com/DQmPM5Fg26qA9SbayuacscZANCeCwyrUHdiUpvcKxNAgvsv/image.png"]}
created2020-07-27 09:20:54
last_update2020-07-27 09:20:54
depth0
children0
last_payout2020-08-03 09:20:54
cashout_time1969-12-31 23:59:59
total_payout_value4.954 HBD
curator_payout_value4.910 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,299
author_reputation125,097,310,898,849
root_title"MiniBitePython - #2 Output result to .txt file with cmd | 使用cmd將結果輸出到.txt文件"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,743,094
net_rshares25,307,608,426,072
author_curate_reward""
vote details (296)