当前位置:网站首页>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
边栏推荐
- Better performance and simpler lazy loading of intersectionobserverentry (observer)
- BeanUtils.setProperty()
- 1 - background project construction
- 09 bloom filter
- What is the function of fileappender in logback?
- Docker's latest super detailed tutorial - docker creates, runs, and mounts MySQL
- 状态机dp(简单版)
- 写点dp
- State machine DP 3D
- 零数科技深度参与信通院隐私计算金融场景标准制定
猜你喜欢

How to establish EDI connection with Scania in Scania?

Docker's latest super detailed tutorial - docker creates, runs, and mounts MySQL

关于大龄读博的几点回答?

【WPF】通过动态/静态资源实现语言切换

stm32 操作W25Q256 W25Q16 spi flash

10 practical uses of NFT

PAT甲级 1146 拓扑顺序

Use custom annotations to verify the size of the list

Sort out the two NFT pricing paradigms and four solutions on the market
![[WPF] realize language switching through dynamic / static resources](/img/23/1e089ce4a07128323824b25897a8c4.png)
[WPF] realize language switching through dynamic / static resources
随机推荐
2-unified return class dto object
【深度学习】数据准备-pytorch自定义图像分割类数据集加载
Multi thread shopping
[summer daily question] Luogu p6336 [coci2007-2008 2] bijele
Can the subset of the array accumulate K
基于高阶无六环的LDPC最小和译码matlab仿真
CDC source can quit after reading MySQL snapshot split
[summer daily question] Luogu p6461 [coci2006-2007 5] trik
黑盒测试常见错误类型说明及解决方法有哪些?
UPC little C's King Canyon
Dilworth 定理
Chaos and future of domestic digital collections
CFdiv1+2-Bash and a Tough Math Puzzle-(线段树单点区间维护gcd+总结)
Docker's latest super detailed tutorial - docker creates, runs, and mounts MySQL
【MYSQL】-【子查询】
PAT甲级 1146 拓扑顺序
Zip gzip tar compression Advanced Edition
强连通分量
do end用法的妙处
【FPGA教程案例42】图像案例2——通过verilog实现图像二值化处理,通过MATLAB进行辅助验证