当前位置:网站首页>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
边栏推荐
猜你喜欢

Chaos and future of domestic digital collections

Pat class a 1146 topology sequence

Prometheus与Grafana

The new generation of public chain attacks the "Impossible Triangle"

stm32 操作W25Q256 W25Q16 spi flash

2022年深圳杯A题破除“尖叫效应”与“回声室效应”走出“信息茧房”

1 - background project construction

监听页面滚动位置定位底部按钮(包含页面初始化定位不对鼠标滑动生效的解决方案)

PAT甲级 1146 拓扑顺序

【深度学习】数据准备-pytorch自定义图像分割类数据集加载
随机推荐
Meeting notice of OA project (Query & whether to attend the meeting & feedback details)
Can the subset of the array accumulate K
NFT 的 10 种实际用途
How to establish EDI connection with Scania in Scania?
Female graduate students do "mind mapping" and quarrel with their boyfriend! Netizen: the "king of infighting" in the quarrel
Sqlmap(SQL注入自动化工具)
Scala higher order (IX): pattern matching in Scala
log4j Layout简介说明
性能更佳、使用更简单的懒加载IntersectionObserverEntry(观察者)
Zip gzip tar compression Advanced Edition
QT topic: basic components (button class, layout class, output class, input class, container class)
I'd like to ask, my flick job writes data in the way of upsert Kafka, but I'm more careful in MySQL
[summer daily question] Luogu p6461 [coci2006-2007 5] trik
JS day 4 process control (if statement and switch statement)
Meizhi optoelectronics' IPO was terminated: annual revenue of 926million he Xiangjian was the actual controller
【MYSQL】-【子查询】
Description of rollingfileappender attribute in logback
[daily question in summer] Luogu p6408 [coci2008-2009 3] pet
stm32 操作W25Q256 W25Q16 spi flash
Scala higher order (10): exception handling in Scala