- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
不等于符号
你好,
我有以下脚本,但它没有选择正确的列名称(“Std”)。 这是脚本:
cols = dt << Get column Names();
for( i = 1, i <= N Items( cols ), i++,
if( contains( cols[i] , "Std") != 1
,
Column( dt, cols[i] ) << Set Data Type( "Character" );
Column( dt, cols[i] ) << Set Modeling Type ("Nominal")
)
);
看起来 != 不起作用。 对此有什么帮助吗? 谢谢
This post originally written in English (US) has been computer translated for you. When you reply, it will also be translated back to English (US).
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
回复:不等于符号
非常感谢您的快速帮助。 将 1 替换为 0 效果非常好。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
回复:不等于符号
我阅读你的脚本的方式,它只会改变列的数据和建模类型立即地以“Std”开头(例如,将修改名为“Std Dev”的列,但不会修改名为“Col Std”的列)。
Contains() 返回您指定的子字符串在字符串中的位置。如果 cols[i] = "Std Dev",Contains(cols[i],"Std") 将返回值 1。如果 cols[i] = "Col Std",则 Contains(cols[i], "Std" ) 将返回值 5,因为“Std”以字符串中的第 5 个字符开头。仅当我尝试名称中不包含“Std”的列名称时,Contains() 才会返回 0。
Contains(cols[i], "Std") != 1 将为所有不立即以“Std”开头的列名称返回 true。
通常,使用 Contains() 确定字符串中是否包含子字符串的方法是使用“!=0”或“">0”。将 1 切换为 0,看看是否有效。
This post originally written in English (US) has been computer translated for you. When you reply, it will also be translated back to English (US).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
回复:不等于符号
非常感谢您的快速帮助。 将 1 替换为 0 效果非常好。
This post originally written in English (US) has been computer translated for you. When you reply, it will also be translated back to English (US).