Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
500 views
in Technique[技术] by (71.8m points)

if-statement - 如何在if语句中使用此空格?(How can I use this blank space in an if statement?)

I am new to programming and I am trying to scan in strings from a text file and assign each string to variables but some lines in the text file have 4 variables I need to assign but others only have 3. On the lines that only have 3 variables I need to assign what would be the 4th variable a value without assigning it the first string in the next line.

(我是编程新手,我试图从文本文件中扫描字符串,并将每个字符串分配给变量,但是文本文件中的某些行有4个我需要分配的变量,而另一些仅3个。在只有3个的行中变量我需要为第4个变量赋值,而无需在下一行中为第一个字符串赋值。)

I managed to get to the point where it assigns all the variables correctly except for the would be 4th variables on the lines with only 3 variables for me to assign.

(我设法达到了正确分配所有变量的地步,只是那一行上的第4个变量只有3个变量可供我分配。)

on these variables it assigns them a blank space but no matter what i try I cannot compare these blank spaces in an if statement to assign them the correct strings.

(在这些变量上,它们会为它们分配一个空格,但是无论我尝试什么,我都无法在if语句中比较这些空格来为它们分配正确的字符串。)

This is the code I have .

(这是我的代码 。)

This is the text file I am scanning .

(这是我正在扫描的文本文件 。)

I have checked value stored in these variables and they are not null it shows a blank space but whenever I try " " or any escape characters it does not work.

(我已经检查了存储在这些变量中的值,它们不是null,它显示空白,但是每当我尝试“”或任何转义字符时,它都不起作用。)

  ask by Jonathan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...