python, c/c++去掉文本的换行符

207 篇文章 7 订阅

 

1 需求分析

把上面的摘要复制到word里面会成这样;

C++实现

 

#include <string> 
#include <fstream> 
#include <iostream> 

using namespace std;

int main()
{
	ifstream myfile("input.txt");
	ofstream outfile("output.txt");
	string temp;
	if (!myfile.is_open())
	{
		cout << "Some errors" << endl;
	}
	while (getline(myfile, temp))
	{
		outfile << temp;
	}

	myfile.close();
	outfile.close();
	return 0;
}

input.txt

Remote collaboration on physical tasks is an emerging use of video telephony. Recent work suggests
that conveying gaze information measured using an eye tracker between collaboration partners could
be beneficial in this context. However, studies that compare gaze to other pointing mechanisms, such
as a mouse-controlled pointer, in video-based collaboration, have not been available. We conducted a
controlled user study to compare the two remote gesturing mechanisms (mouse, gaze) to video only
(none) in a situation where a remote expert saw video of the desktop of a worker where his/her
mouse or gaze pointer was projected. We also investigated the effect of distraction of the remote
expert on the collaborative process and whether the effect depends on the pointing device. Our result
suggests that mouse and gaze pointers lead to faster task performance and improved perception of
the collaboration, in comparison to having no pointer at all. The mouse outperformed the gaze when
the task required conveying procedural instructions. In addition, using gaze for remote gesturing
required increased verbal effort for communicating both referential and procedural messages.

君不见,黄河之水天上来,奔流到海不复回。
君不见,高堂明镜悲白发,朝如青丝暮成雪。

人生得意须尽欢,莫使金樽空对月。
天生我材必有用,千金散尽还复来。

烹羊宰牛且为乐,会须一饮三百杯。
岑夫子,丹丘生,将进酒,杯莫停。
与君歌一曲,请君为我倾耳听。

钟鼓馔玉不足贵,但愿长醉不复醒。
古来圣贤皆寂寞,惟有饮者留其名。
陈王昔时宴平乐,斗酒十千恣欢谑。
主人何为言少钱,径须沽取对君酌。
五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。


Python实现

#  coding:utf-8
import codecs

newlines = []
fileOpen = codecs.open("ReadMe.txt", "r", "UTF-8")  # 打开以utf-8格式
fileSave = codecs.open("input.txt", "w", "UTF-8")  # 保存utf-8格式
for line in fileOpen.readlines():
    line = line.strip()
    fileSave.write(line + " ")
fileSave.close()

 

 

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值