当前位置:网站首页>Cs61abc sharing session (VI) detailed explanation of program input and output - standard input and output, file, device, EOF, command line parameters
Cs61abc sharing session (VI) detailed explanation of program input and output - standard input and output, file, device, EOF, command line parameters
2022-07-29 07:37:00 【Sanfeng grocery store】
List of articles
Sharing session link
2022 year 7 month 23 Long term link to the daily sharing meeting :https://meeting.tencent.com/dm/Qet4sVXmOccd
Share time :9 spot 20 To 9 spot 50
The video is recorded at the bottom
List of articles
- List of articles
- Sharing session link
- standard output /dev/stdout
- The standard error /dev/stderr
- Interactive standard input /dev/stdin
- EOF Ending standard input /dev/stdin
- File input and output
- Linux Device output and redirection
- Input of command line parameters
- debug
- Add
- Demo code
- Find the organization
- questionnaire
- Video recording
- official account
- thank

standard output /dev/stdout
It's the keyboard
Display... On the terminal .
The standard error /dev/stderr
error message
It is also displayed on the terminal .
Although it shows in the same place , But you can and stdin distinguish . By redirecting symbols >
Interactive standard input /dev/stdin
Line breaks and spaces distinguish each input .
3
a 1 bccc
python For example :
try :
while True:
line = input()
# process line
except EOFError:
pass
How to deal with it EOF Well ?
EOF Ending standard input /dev/stdin
End Of File Abbreviation , This character usually exists at the end of the file to indicate the end of the file .
EOF Express
In the end :CTRL + D
C In language :-1, The header file has a definition stdio.h
python: An empty string
stay Linux In the system ,EOF Not a character at all , But when the system reads the end of the file , A signal value returned ( That is to say -1). As for how the system knows the end of the file , According to the data, it is by comparing the length of the file .
EOF Handle
Without user input , Then use standard output .
Use input The way :
try :
while True:
line = input()
# process line
except EOFError:
pass
Use stdin The way , encounter EOF It's empty :
while True:
line = sys.stdin.readline()
if line = '':
break
else:
# Do what
pass
C++ The way , encounter EOF, The return value is 0:
while (cin >> a) {
// process
}
File input and output
Input direct full read .
Output doesn't matter EOF.
But there is a EOF Of .
Linux Device output and redirection
/dev/null
/dev/zero
1 The standard input
2 standard output
The default is to process standard input :./p.py > a.txt
If you want to change it , Explain the changes clearly . yes 1 The file of , still 1 This stdin
1 >&2
1 > /dev/null 2 >/dev/null
stay shell Application in
if cat a ;then
:
fi
if cat a 1 > /dev/null 2 >/dev/null;then
:
fi
Input of command line parameters
debug
All inputs and outputs are ok debug, But I don't know pycharm Words , There may be a hole .
pycharmdebug when , Input the standard, input the unresponsive processing method
stay pycharm in debug Note that deselect .
Add
About terms , Is there anything that needs to be modified ?
Supplementary place
problem
Demo code
https://github.com/SFUMECJF/weekly-report/
Find the organization
Telegram : https://t.me/±FOA9RSORNJlNzJl
cs61abc Basic courses qq Group : 482582963
Embedded communication group qq: 1057158348
CMake Communication group qq:433323162
CS 106B C++ Data structure group qq:1023037623
CMake Online e-books :https://sfumecjf.github.io/cmake-examples-Chinese/
official account : Sanfeng grocery store
questionnaire
I hope you can give me some suggestions for this sharing meeting , Link or scan code ~
https://jinshuju.net/f/Fj4Crr

Video recording
Update on bilibili:https://space.bilibili.com/39544331/channel/seriesdetail?sid=2315808
official account

thank
边栏推荐
猜你喜欢

Use of gcc/g++
Scala higher order (IX): pattern matching in Scala

梳理市面上的2大NFT定价范式和4种解决方案

I, 28, a tester, was ruthlessly dismissed in October: I want to remind people who are still learning to test

SEGGER 的硬件异常 分析

Chaos and future of domestic digital collections

Meizhi optoelectronics' IPO was terminated: annual revenue of 926million he Xiangjian was the actual controller

2-unified return class dto object

国内数字藏品的乱象与未来

PAT甲级 1146 拓扑顺序
随机推荐
Pat class a 1150 traveling salesman problem
Introduction to logback appender
3-global exception handling
状态机dp(简单版)
CFdiv1+2-Bash and a Tough Math Puzzle-(线段树单点区间维护gcd+总结)
性能更佳、使用更简单的懒加载IntersectionObserverEntry(观察者)
Description of rollingfileappender attribute in logback
【MYSQL】-【子查询】
Leetcode 209. subarray with the smallest length (2022.07.28)
Android interview question | how to write a good and fast log library?
Zip gzip tar compression Advanced Edition
zip gzip tar压缩进阶版
What are the answers about older bloggers?
7-2 计算正五边形的面积和周长 (25分)
程序的静态库与动态库的区别
零数科技深度参与信通院隐私计算金融场景标准制定
【暑期每日一题】洛谷 P1601 A+B Problem(高精)
Pat class a 1146 topology sequence
Thinkphp6 realizes database backup
[daily question in summer] Luogu p6408 [coci2008-2009 3] pet