有人可以将此Python代码转换为C#吗? [英] Could someone have a go at converting this Python code to C#?

查看:496
本文介绍了有人可以将此Python代码转换为C#吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到了完美的代码片段,可以完成我想要的东西并使其在Python 2中运行,但是我非常需要将其放在C#中,因为这就是我在编写主应用程序时使用的代码.手动转换已经很久了,并且没有在线转换器,因为两种语言之间的差异太大,无法自动转换.我知道这是一个很大的问题,但是你们有什么改变可以将代码从Python 2转换为C#吗?该代码在第一个链接中,而它应该做什么"在最后一个链接的最后一个帖子中.谢谢您的帮助.

我认为我的主要问题是,Python在初始化变量时烦人地不需要数据类型,这使得转换变得更加困难...

代码:http://04819193935789338545.googlegroups.com/attach/635a5f7d08fa9a7a/check_capabilities.py?part=4&view=1&vt=ANaJVrFW4aLpCAf5vlei2dM7vN-AWAK3Kjd4mSUAqxk55sqmPSn_MfPSCUBALdPXaKggUyRtWbqz9ixrxBDndGrgTdBUHiEkdOMP5Dlc_peGxOVgNSoUkoQ
页面:https://groups.google.com/forum/#!topic/metoffice-datapoint/lO7TysG4-CI
顺便说一下,代码与Google帖子中的附件是同一文件.

I have found the perfect piece of code that does what I want for something and have it running in Python 2 but I desperately need it to be in C# as that is what I am writing my main application in. I have tried for ages to convert it manually and there are no online converters because the two languages are just too different to convert automatically. I know it is a big ask but is there any change one of you could have a go at converting the code from Python 2 into C#? The code is in the first link and the ''what it should do'' is in the last post of the last link. Thank you for any help.

I think my main problem is that Python annoyingly does not require data types when initializing variables which makes it much harder to convert...

Code: http://04819193935789338545.googlegroups.com/attach/635a5f7d08fa9a7a/check_capabilities.py?part=4&view=1&vt=ANaJVrFW4aLpCAf5vlei2dM7vN-AWAK3Kjd4mSUAqxk55sqmPSn_MfPSCUBALdPXaKggUyRtWbqz9ixrxBDndGrgTdBUHiEkdOMP5Dlc_peGxOVgNSoUkoQ
Page: https://groups.google.com/forum/#!topic/metoffice-datapoint/lO7TysG4-CI
By the way the code is the same file as the attachment in the Google post

推荐答案

只需用C#编写代码.它与Python有很多相似之处,但是语言却有很大不同,您可能使用的框架可能会更加不同.我从代码示例中看到的与.NET和C#有很大不同.您不能谈论自动翻译之类的东西.继续吧:在输入时,您应该了解代码的目标,Python代码,对.NET和C#的了解,在输出时— C#中的新代码.

—SA
Just write the code in C#. It has a lot of similarities with Python, yet the languages are very different, and the frameworks you might have used can be even more different. What I see from code sample, is very different from .NET and C#. You could not talk about anything like automatic translation. Just go ahead: on input, you should have understanding of the goals of your code, Python code, understanding of .NET and C#, on output — new code in C#.

—SA


这篇关于有人可以将此Python代码转换为C#吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆