VBA转换txt文件编码

代码如下:

一,前期绑定:

Sub 转换txt文件编码()
   Dim stm As New ADODB.Stream
   Dim str As String
   Dim ins As String
   ins = ThisWorkbook.Path & "\数据.txt"
   With stm
      .Charset = "GB2312"
      .Open
      .LoadFromFile ins
      str = .ReadText
      .Close
      .Charset = "utf-8"
      .Open
      .WriteText str
      .SaveToFile ins, adSaveCreateOverWrite
      .Close
   End With
   Set stm = Nothing
End Sub

二,后期绑定:

Sub 转换txt文件编码()
   Dim stm As Object
   Set stm = CreateObject("ADODB.Stream")
   Dim str As String
   Dim ins As String
   ins = ThisWorkbook.Path & "\数据.txt"
   With stm
      .Charset = "GB2312"
      .Open
      .LoadFromFile ins
      str = .ReadText
      .Close
      .Charset = "utf-8"
      .Open
      .WriteText str
      .SaveToFile ins, 2
      .Close
   End With
   Set stm = Nothing
End Sub

  

 

上一篇:Pytorch基础操作 —— 14. torch.unsqueeze 张量维度扩张


下一篇:resMLP的PyTorch代码和分析(一)