如何在 Python 中完成此 JSL 到基数 36 的转换。
txt = Hex( (Today() - Informat( "01/01/1970", "mm/dd/yyyy" ) - In Hours( 8 )) * 1000 + 600000 + Day( Today() ), base( 36 ) );
a = Today();
b = Informat( "01/01/1970", "mm/dd/yyyy" );
c = In Hours( 8 );
d = Day( Today() );
e = (a - b - c) * 1000 + 600000 + d;
f = Hex( (a - b - c) * 1000 + 600000 + d, base( 36 ) );
我多次询问过ChatGPT,结果与JSL的结果不一致。仅向熟悉 JSL 和 python 的专家寻求帮助。非常感谢!
自动化和脚本视窗回复:如何在 Python 中完成 JSL 到 36 进制的转换。您在哪一部分遇到了问题?是建立要转换的数字吗?还是转换本身?
回复:如何在 Python 中完成 JSL 到 36 进制的转换。你对 JSL 中这个函数的理解
txt = Hex( (Today() - Informat( "01/01/1970", "mm/dd/yyyy" ) - In Hours( 8 )) * 1000 + 600000 + Day( Today() ), base( 36 ) );
如何在 python 中计算出相同的结果
我也不明白Informat(“01/01/1970”、“mm/dd/yyyy”)。所以我们不知道ChatGPT的答案在哪里。
它会计算一个Token的结果,如果计算不正确。那么就无法POST下载。其实就是python计算出来的结果无法下载。
谢谢!
ChatGPT
import datetime
# Step 1: Current time (China's East 8 time zone)
now = datetime.datetime.now()
# Step 2: Date of January 1, 1970
epoch = datetime.datetime(1970, 1, 1)
# Step 3: Calculate the difference in seconds between the current time and January 1, 1970, and subtract 8 hours
time_diff = (now - epoch).total_seconds() - (8 * 3600)
# Step 4: Convert the time difference to milliseconds, add 600,000, and add today's day of the month
milliseconds = time_diff * 1000
e = milliseconds + 600000 + now.day
# Step 5: Convert the result to a base-36 representation
def to_base36(num):
chars = '0123456789abcdefghijklmnopqrstuvwxyz'
base36 = ''
while num > 0:
num, i = divmod(int(num), 36)
base36 = chars[i] + base36
return base36
# Output the base-36 value
result = to_base36(e)
print("Python calculated result:", result)
# Output the current precise timestamp
print("Current timestamp:", now)回复:如何在 Python 中完成 JSL 到 36 进制的转换。如果你不理解第一部分,你必须从那部分开始。在格式中,使用指定的格式/模式将字符串转换为 JMP 日期数字

在你的情况下是 2082844800。另外,如果你使用 JMP,为什么要在 Python 中执行转换?你可以使用 run_jsl 在 Python 中运行 JSL
回复:如何在 Python 中完成 JSL 到 36 进制的转换。谷歌搜索:Python base36
给出以下 base36 转换,包括使用 numpy 的 2 行解决方案。
https://stackoverflow.com/questions/1181919/python-base-36-encoding
Python 和 base36 的众多搜索结果之一。
还要了解 Python 的纪元日期是 1970 年 1 月 1 日。如果您获取 JMP 的原始日期值,则纪元日期是 1904 年 1 月 1 日。此外,在对秒进行直接时间转换时,请确保还考虑闰年。
回复:如何在 Python 中完成 JSL 到 36 进制的转换。这个python中的JSL怎么传递给python呢?
我会浏览一下粘贴板
谢谢!

回复:如何在 Python 中完成 JSL 到 36 进制的转换。在 JMP 中,无需使用剪贴板在 jmp 和 python 之间移动信息(建议您阅读https://www.jmp.com/support/help/en/18.0/#page/jmp/python.shtml# )。
import jmp
txt = "initial";
print(txt);
jmp.run_jsl("""
txt = "hello world";
Python Send(txt);
""")
print(txt);

回复:如何在 Python 中完成 JSL 到 36 进制的转换。我不会

回复:如何在 Python 中完成 JSL 到 36 进制的转换。您忽略的根本问题是 JSL 环境和 Python 环境具有不同的变量范围。在 JSL 中,当名称默认为此处 (0);或未指定时,名称将进入全局命名空间。当名称默认为此处 (1);时,它们位于“此处”命名空间中;或者如果您选择通过 JSL 创建另一个命名空间,它们位于特定命名空间内。如果它们是当前数据表的列引用,则会检查其他特殊内容(如 :age)。这是在边界的 JSL 侧。在 Python 侧,在 Python 中创建的变量最终会出现在适当范围的 Python 字典中。在脚本主体的 globals() 字典中。每个模块、函数……都有自己的本地字典。Python 和 JSL 不会自动彼此共享变量。这需要您执行一项操作以将 JSL 变量“发送”到 Python 环境或将 Python 值“获取”回 JSL 环境。为此,Python Send(v) 接收 JSL 值 v,并创建一个名为 v 的 Python 变量,其中包含 v 值的副本。一些特殊类型(如数据表和矩阵)作为对实际对象的引用传递,而不是副本。但大多数值都以副本的形式出现。jV = Python Get(pV);在 Python 环境中查找 pV 变量,并将值复制到 JSL 变量 jV。
正如@jthi提到的,有很多 JMP 文档都谈到了此功能。从 JMP 14 开始,send() / get() 功能一直是 Python 集成的基础。请花时间浏览我们的文档和示例脚本。帮助菜单中的脚本索引是内置的 JMP 文档,用于 JSL 和 Python。在脚本索引中,“所有类别”显示所有内容,旁边有一个搜索字段。搜索 Python 将快速显示所有 JSL Python 功能以及描述和可运行示例。如果您选择“Python”类别,它会进行过滤以显示 Python 环境支持的所有新 JMP 18+ 功能。在这里,您将找到描述和可运行示例,展示集成的 JMP 18+ Python 端的功能。最后,在 Python 环境中,文档字符串已被利用,因此您可以使用 Python 的内置帮助功能。例如 help( jmp.DataTable )



正如您所发现的,Python 软件包的灵活性允许您创建自己的数据传递方式。花时间阅读我们提供的文档和示例。试用它们并了解它们的功能,将大大有助于弄清楚如何最好地利用 JMP 的 Python 集成。
另外,使用 Chat GPT 或其他 AI 工具编写代码只有在您知道代码应该如何工作时才真正有用。这就像信任网站文章一样,您需要对事物的工作原理有足够的了解(Python、JSL 等),才能知道您获得的代码是否准确、是否几乎可以工作、概念是否正确,或者只是完全虚假的信息。最后,由于 JMP 18 的新颖性,AI 对当前 JMP 18+ Python 集成的了解可能比 JMP 14-17 的信息少很多。我相信最好的信息来源是我们的文档、我们的脚本索引和包含的 $SAMPLE_SCRIPTS 目录。
回复:如何在 Python 中完成 JSL 到 36 进制的转换。感谢 保罗!

回复:如何在 Python 中完成 JSL 到 36 进制的转换。谢谢专家!
好的

回复:如何在 Python 中完成 JSL 到 36 进制的转换。我有两个问题想请教专家:
1. 如何在 python 中连接两个 JMP 表?
2、如何将下面的python修改为python asyncio异步执行形式?
谢谢专家!
import jmputils
import jmp
from datetime import datetime, timedelta
today = datetime.today()
dates = []
for i in range(200):
dates.append((today - timedelta(days=i)).strftime('%Y%m%d'))
j = 0
for date in dates:
#print(date)
j += 1
jmp.run_jsl('''
b=Python Get(date);
d1=New Table("o",Add Rows(1),New Column("date",Set Values({b})));
Python Send(d1)
''')
#print(d1)
jmp.run_jsl('''
j=Python Get(j);
//b=Python Get(d1);
if(j==1,d2=d1;d2<<SETNAME></SETNAME><SPAN class="">我还是没有答案。</SPAN><SPAN class="">期待专家帮助。</SPAN>
回复:如何在 Python 中完成 JSL 到 36 进制的转换。我问过ChatGPT几次,python的asyncio框架是这样写的
但执行总是不成功。
向您所在社区的专家寻求帮助。
谢谢!
import asyncio
import concurrent.futures
import jmp
# Define a global variable kk
kk = 1
# Create an asynchronous function to run the JSL script
async def run_jsl_script():
global kk
loop = asyncio.get_event_loop()
# Simplified JSL script
jsl_script = f'''
Print("Value of kk: {kk}");
b = Python Get({kk});
Print("Value of b: ", b);
d1 = New Table("o", Add Rows(1), New Column("date", Set Values({{b}})));
if (b == 1,
d2 = d1;
d2 << Set Name("Name 2");
Print("Table d1 copied to d2 with new name.");
,
current data table(d2);
d2 << Concatenate(Data Table(d1), Append to first table);
Close(d1, nosave);
);
Python Send(d1);
'''
# Print the JSL script content for debugging
print("JSL script to be executed:")
print(jsl_script)
try:
# Use a thread pool to run the synchronous JSL script
with concurrent.futures.ThreadPoolExecutor() as pool:
# Call jmp.run_jsl function
await loop.run_in_executor(pool, lambda: jmp.run_jsl(jsl_script))
except Exception as e:
print(f"Error occurred: {e}")
# Update the kk variable
kk += 1
print(f"Current value of kk: {kk}")
# Main asynchronous function
async def main():
# Example of running the JSL script multiple times
for _ in range(3): # For example, run three times
await run_jsl_script()
print("All JSL scripts executed.")
# Run the main function
if __name__ == "__main__":
asyncio.run(main())